package hdo.app.hdonline.adapters;

import hdo.app.hdonline.R;
import hdo.app.hdonline.models.FilmDetail;
import android.content.Context;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.SpinnerAdapter;

import com.nostra13.universalimageloader.core.ImageLoader;

public class GalleryImageAdapter implements SpinnerAdapter {
	private Context mContext;
	private Integer[] mImageIds = { R.drawable.phim,
			R.drawable.ic_launcher, R.drawable.phim,
			R.drawable.phim, R.drawable.ic_launcher,
			R.drawable.phim, R.drawable.ic_launcher,
			R.drawable.phim };

	ImageLoader imageLoader; 
	
	public GalleryImageAdapter(Context context) {
		mContext = context;
		
	}

	public int getCount() {
		return mImageIds.length;
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	// Override this method according to your need
	public View getView(int index, View view, ViewGroup viewGroup) {
		// TODO Auto-generated method stub
		ImageView i = new ImageView(mContext);

		FilmDetail fd= new FilmDetail();
		fd.setType("phim-le");
		fd.loadData();
		String url = "http://i.hdonline.vn/resources/images/thumb-s/chia-tay-cung-la-tinh-yeu-2007-thumb.jpg";
//		imageLoader.DisplayImage(fd.thumb[index], 0, i);
		imageLoader.displayImage(url, i);
		
		//i.setImageResource(mImageIds[index]);
		i.setLayoutParams(new Gallery.LayoutParams(200, 200));

		//i.setScaleType(ImageView.ScaleType.FIT_XY);

		return i;
	}

	@Override
	public int getItemViewType(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void registerDataSetObserver(DataSetObserver observer) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void unregisterDataSetObserver(DataSetObserver observer) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public View getDropDownView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		return null;
	}
}
